﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using ERP_RORZE_PERMISSION.Base;
using ERP_RORZE_PERMISSION.Base.Objects;
using ERP_RORZE_PERMISSION.UserControls;

namespace ERP_RORZE_PERMISSION.Forms
{
    public partial class frm_UserInfo : DevExpress.XtraEditors.XtraForm
    {
        private DataTable dtuser;
        private Permission role;
        public frm_UserInfo()
        {
            InitializeComponent();
            this.CancelButton = this.btAdd;
            this.ActiveControl = btAdd;
            role = new Permission();
        }

        private void frm_UserAdd_Load(object sender, EventArgs e)
        {
            if (role.Is_Login())
            {
                dtuser =
                BaseDAO.ExecuteQuery("SELECT [222_Users].UserName, [222_Users].StaffID, [222_Users].UserGroupID, " +
                                     "          [222_Staff].StaffName, [222_UserGroup].GroupName " +
                                     "  FROM [222_Users] INNER JOIN " +
                                     "          [222_Staff] ON [222_Users].StaffID = [222_Staff].StaffID " +
                                     "          left join [222_UserGroup] on [222_UserGroup].GroupID = [222_Users].UserGroupID" +
                                     "  WHERE [222_Users].UserName = N'" + role.UserName + "'");
                if (dtuser.Rows.Count>0)
                {
                    lblUsername.Text = dtuser.Rows[0]["UserName"].ToString();
                    lblStaffID.Text = dtuser.Rows[0]["StaffID"].ToString();
                    lblFullname.Text = dtuser.Rows[0]["StaffName"].ToString();
                    lblGroup.Text = dtuser.Rows[0]["GroupName"].ToString();
                    //lblDepartment.Text = dtuser.Rows[0]["UserName"].ToString();
                }
            }
            else
            {
                Utilities.MessageErrorOk(PermissionConstants.Message.LoadFailed);
                this.Dispose();
            }

        }

        private void btAdd_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }


    }
}